package boxe.timer.manager;

/**
 * ;anager to resize the elements's windows
 * 
 * @author Julien Perriard
 * @date 25.05.2010
 *
 */

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import boxe.timer.env.Propertie;
import boxe.timer.view.MainWindow;

public class ResizeManager implements ComponentListener{
	
	/*
	 * Current view
	 */
	private MainWindow window;
	
	/*
	 * initial size
	 */
	private int initHeight;

	
	public ResizeManager(MainWindow mainWindow) {
		this.window = mainWindow;
		initHeight = window.getSize().height;
	}
	
	/*
	 * change elements's size
	 */
	public void changeSizeElement(){
		changeTimer();
	}
	
	private void changeTimer() {
		Dimension dim = window.getSize();
		int width = (int) dim.getWidth();
		int height =(int) dim.getHeight();
		int size = Propertie.SIZETIMER;
		/*if (newHeight < Propertie.TIMER_HEIGHT)
			newHeight = Propertie.TIMER_HEIGHT;
		*/
		float rate = ((float) height / initHeight);

		window.getLblTimer().setFont(new Font("Arial", Font.BOLD,(int)(Propertie.SIZETIMER * rate * Propertie.COEFF_TIMER) ));
		window.getLblCountRound().setFont(new Font("Arial", Font.BOLD, (int)(Propertie.SIZEROUND * rate) ));
		window.getLblTitle().setFont(new Font("Arial", Font.BOLD,(int)(Propertie.SIZETITLE * rate) ));
	}

	/*
	 * Getters and Setters
	 */
	public MainWindow getWindow() {
		return window;
	}



	public void setWindow(MainWindow window) {
		this.window = window;
	}



	/**
	 * Component listener methods
	 */
	public void componentHidden(ComponentEvent e) {
		
	}

	public void componentMoved(ComponentEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void componentResized(ComponentEvent e) {
		JFrame frame= (JFrame) e.getComponent();
		Dimension dim = new Dimension(); 
		changeTimer();
	}

	public void componentShown(ComponentEvent e) {
		// TODO Auto-generated method stub
		
	}
	

}
